/**
 * Example of promise inside promise
 */


// example of promise 2
async function example2() {
	return new Promise((resolve) => {
		console.log('inside promise 2');
		resolve('some value from promise 2');
	});
}

// example of promise 1
async function example() {
	return new Promise((resolve) => {
		(async() => {
			console.log('inside promise 1');
			var ret = await example2();
			console.log('return from promise 2: '+ret);
			resolve('some value');
		})();
	});
}

async function init() {
	console.log('before promise 1');
	var ret = await example();
	console.log('promise 1 returned: '+ret);
	console.log('after promise 1');
}

init();
